import 'package:flutter/material.dart';
import 'package:flutter_09_game/base/widget/base_list_more_get_builder.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/models/model_game_round_join.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/utils_bet_record.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_dropdown.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_top_crypto.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_game_stats.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_item.dart';
import 'package:flutter_09_game/widgets/empty/empty_no_data.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'profile_bet_record_hash_logic.dart';

class ProfileBetRecordHashPage extends StatelessWidget {
  ProfileBetRecordHashPage({super.key});

  final ProfileBetRecordHashLogic logic = Get.put(ProfileBetRecordHashLogic());

  @override
  Widget build(BuildContext context) {
    return BaseListMoreGetBuilder<ProfileBetRecordHashLogic>(
        bodyTopViewBuilder: (_) {
      return Column(
        children: [
          WidgetBetRecordTopCrypto(
              selectorTagRx: logic.selectorTagRx,
              options: UtilsBetRecord.betSource),
          Obx(() {
            return WidgetBetRecordDropdown(
              teamRows: UtilsBetRecord.options,
              statusRows: UtilsBetRecord.statusRows,
              timeRows: UtilsBetRecord.timeRows,
              symbolRows: UtilsBetRecord.symbolRows,
              symbolRx: logic.symbolRx,
              timeRx: logic.timeRx,
              statusRx: logic.statusRx,
              teamRx: logic.teamRx,
              gameRows: logic.gameRows,
              gameRx: logic.gameRx,
              editingController: logic.idController,
              userEditingController:
                  UtilsBetRecord.options.indexOf(logic.teamRx.value) == 0
                      ? null
                      : logic.userController,
              onRequestRefresh: (value) {
                logic.refreshController.requestRefresh();
              },
              onTimeSelection: (value) {
                logic.updateTimeSelection(value);
              },
            );
          }),
        ],
      );
    }, headerBuilder: (l) {
      return Visibility(
          visible: (logic.roundJoin.stats ?? []).isNotEmpty,
          child: WidgetGameStats(
            stats: logic.roundJoin.stats ?? [],
          ).marginOnly(top: 16.w, left: 16.w, right: 16.w)
          // showTRX: joinType == 2,
          );
    }, builder: (_) {
      // bool showHeader = (logic.roundJoin.stats ?? []).isNotEmpty;
      // return CustomScrollView(
      //   slivers: [
      //     SliverPadding(
      //       padding: showHeader
      //           ? EdgeInsets.symmetric(
      //               horizontal: 16.w,
      //             ).copyWith(
      //               top: 16.w,
      //             )
      //           : EdgeInsets.zero,
      //       sliver: SliverToBoxAdapter(
      //           child: Visibility(
      //         visible: showHeader,
      //         child: WidgetGameStats(
      //           stats: logic.roundJoin.stats ?? [],
      //           // showTRX: joinType == 2,
      //         ),
      //       )),
      //     ),
      return logic.list.isNotEmpty
          ? SliverPadding(
              padding:
                  EdgeInsets.only(bottom: 16.w + ScreenUtil().bottomBarHeight),
              sliver: SliverList.builder(
                itemCount: logic.list.length,
                itemBuilder: (context, index) {
                  final item = logic.list[index];
                  return WidgetBetRecordItem(
                    data: item,

                  );
                },
              ),
            )
          : SliverToBoxAdapter(
              child: SizedBox(
                width: 1.sw,
                child: Padding(
                  padding: EdgeInsets.only(top: 108.w),
                  child: EmptyNoData.notDataView(),
                ),
              ),
              // )
              // ],
            );
    });
  }
}
